home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 42 / Amiga Format AFCD42 (Issue 126, Aug 1999).iso / -serious- / hardware / blizkick / modules / fixmath404.asm < prev    next >
Assembly Source File  |  1999-05-17  |  3KB  |  126 lines

  1. ; FILE: Source:modules/FixMath404.ASM          REV: 13 --- Fix V40.4 math library
  2.  
  3. ;
  4. ; Fix mathieeesingbas 40.4 -Module
  5. ; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  6. ; This patch module will fix mathieeesingbas.library V40.4 bug in functions
  7. ; IEEESPMul() and IEEESPDiv() [this bug occurs if you don't have 68881 or
  8. ; 68882 FPU].
  9. ;
  10. ; Written by Harry Sintonen.
  11. ; This source code is Public Domain.
  12. ;
  13.  
  14.     incdir    "include:"
  15.     include    "blizkickmodule.i"    ; Some required...
  16.  
  17.  
  18.     SECTION    PATCH,CODE
  19. _DUMMY_LABEL
  20.     BK_PTC
  21.  
  22. ; Code is run with following incoming parameters:
  23. ;
  24. ; a0=ptr to ROM start (buffer)    eg. $1DE087B8
  25. ; a1=ptr to ROM start (ROM)    eg. $00F80000 (do *not* access!)
  26. ; d0=ROM lenght in bytes    eg. $00080000
  27. ; a2=ptr to _FindResident routine (will search ROM buffer for resident tag):
  28. ;    CALL: jsr (a2)
  29. ;      IN: a0=ptr to ROM, d0=rom len, a1=ptr to resident name
  30. ;     OUT: d0=ptr to resident (buf) or NULL
  31. ; a3=ptr to _InstallModule routine (can be used to plant a "module"):
  32. ;    CALL: jsr (a3)
  33. ;      IN: a0=ptr to ROM, d0=rom len, a1=ptr to module, d6=dosbase
  34. ;     OUT: d0=success
  35. ; a4=ptr to _Printf routine (will dump some silly things (errormsg?) to stdout ;-)
  36. ;    CALL: jsr (a4)
  37. ;      IN: a0=FmtString, a1=Array (may be 0), d6=dosbase
  38. ;     OUT: -
  39. ; d6=dosbase, a6=execbase
  40. ;
  41. ; Code should return:
  42. ;
  43. ; d0=true if succeeded, false if failed.
  44. ; d1-d7/a0-a6 can be trashed. a7 *must* be preserved! ;-)
  45.  
  46.     moveq    #0,d7
  47.  
  48.     cmp.w    #40,($C,a0)        ; Requires KS V40+
  49.     blo.b    .exit
  50.  
  51.     move.l    a1,-(sp)
  52.     lea    (_mname,pc),a1        ; _FindResident
  53.     jsr    (a2)
  54.     move.l    (sp)+,a1
  55.     tst.l    d0
  56.     beq.b    .exit
  57.     move.l    d0,a2            ; a2=mathlib resident
  58.  
  59.     cmp.b    #40,(RT_VERSION,a2)    ; V40
  60.     bne.b    .exit
  61.     cmp.b    #RTF_COLDSTART,(RT_FLAGS,a2) ; Coldstart
  62.     bne.b    .exit
  63.     move.l    (RT_IDSTRING,a2),d0
  64.     beq.b    .exit
  65.     move.l    d0,a5
  66.     sub.l    a1,a5
  67.     add.l    a0,a5            ; a5=ptr in buffer
  68. .find    cmp.b    #'0',(a5)+        ; 40.4
  69.     bne.b    .find
  70.     addq.l    #1,a5
  71.     cmp.b    #'4',(a5)+
  72.     bne.b    .exit
  73.     cmp.b    #' ',(a5)
  74.     bne.b    .exit
  75.  
  76.     move.l    (RT_INIT,a2),d0        ; Test RT_INIT
  77.     beq.b    .exit
  78.     sub.l    a1,d0
  79.     add.l    a0,d0
  80.     move.l    d0,a2            ; a2=ptr in buffer
  81.  
  82.     move.w    #$41F9,d0        ; Find second "lea ABS,a0"
  83. .find2    cmp.w    (a2)+,d0
  84.     bne.b    .find2
  85. .find3    cmp.w    (a2)+,d0
  86.     bne.b    .find3
  87.     move.l    (a2),a2
  88.     sub.l    a1,a2
  89.     add.l    a0,a2
  90.  
  91.     move.w    (a2)+,d0        ; Test for $FFFF
  92.     addq.w    #1,d0
  93.     bne.b    .exit
  94.  
  95.     lea    (12*2,a2),a2        ; 13th & 14th function
  96.     cmp.l    #$001A001C,(a2)        ; Check for invalid
  97.     bne.b    .aok            ; Already ok!
  98.     move.l    #$063606A0,(a2)        ; Stuff correct!
  99.     moveq    #1,d7
  100.  
  101. .exit    move.l    d7,d0            ; Valid counter?
  102.     bne.b    .xit
  103.     lea    (_error1,pc),a0        ; a0=fmt
  104.     pea    (_mname,pc)
  105.     move.l    sp,a1            ; a1=array
  106.     jsr    (a4)            ; Call _Printf
  107.     addq.l    #4,sp
  108.     moveq    #0,d0            ; Return fail
  109. .xit    rts
  110.  
  111. .aok    lea    (_error2,pc),a0
  112.     jsr    (a4)            ; Call _Printf
  113.     moveq    #1,d0
  114.     rts
  115.  
  116.  
  117. _mname    dc.b    'mathieeesingbas.library',0
  118.  
  119. _error1    dc.b    'FixMath404: This patch requires V40 ROM with %s V40.4!',10,0
  120. _error2    dc.b    'FixMath404: Already OK!',10,0
  121.  
  122.  
  123.     SECTION    VERSION,DATA
  124.  
  125.     dc.b    '$VER: FixMath404_PATCH 1.0 (1.10.96)',0
  126.